load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")

# TODO: Open this up.
package(default_visibility = ["//visibility:private"])

DEPENDENCIES = [
    # Keep sorted.
    "@crate_index//:base64",
    "@crate_index//:clap",
    "@crate_index//:ic-agent",
    "@crate_index//:ic-certification",
    "@crate_index//:serde",
    "@crate_index//:serde_cbor",
    "@crate_index//:tokio",
]

LIBRARY_SRCS = glob(
    ["src/**/*.rs"],
    exclude = [
        # Keep sorted.
        "**/*tests.rs",
        "src/main.rs",
    ],
)

rust_library(
    name = "signed-canister-reply",
    srcs = LIBRARY_SRCS,
    crate_name = "ic_nervous_system_tools_signed_canister_reply",
    deps = DEPENDENCIES,
)

rust_binary(
    name = "signed-canister-reply_tool",
    srcs = [
        # Keep sorted.
        "src/main.rs",
    ],
    binary_name = "signed-canister-reply",
    deps = [
        # Keep sorted.
        ":signed-canister-reply",
        "@crate_index//:clap",
        "@crate_index//:tokio",
    ],
)

rust_test(
    name = "signed-canister-reply_test",
    srcs = glob(
        ["src/**"],
        exclude = ["src/main.rs"],
    ),
    compile_data = [
        # Keep sorted.
        "signed_reply.cbor",
    ],
    data = [
        # Keep sorted.
        "//rs/nervous_system/common/test_canister",
        "//rs/pocket_ic_server:pocket-ic-server-head-nns",
    ],
    env = {
        # Keep sorted.
        "POCKET_IC_BIN": "$(rootpath //rs/pocket_ic_server:pocket-ic-server-head-nns)",
        "TEST_CANISTER_WASM_PATH": "$(rootpath //rs/nervous_system/common/test_canister)",
    },
    deps = DEPENDENCIES + [
        # Keep sorted.
        "//packages/pocket-ic",
        "//rs/rust_canisters/canister_test",
        "@crate_index//:candid",
        "@crate_index//:hex",
        "@crate_index//:lazy_static",
        "@crate_index//:tempfile",
    ],
)
